#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
int n;
int arr[305];
long long sum;
int compare(const void* p1, const void* p2)
{
	if (*(int*)p1 > *(int*)p2)return 1;
	else return 0;
}
int main()
{
	cin >> n;
	for (int i = 1; i <= n; i++)
		scanf("%d", &arr[i]);
	qsort(arr + 1, n, sizeof(int), compare);
	int l = 0, r = n;
	int now = 0;
	while (l <= r)
	{
		if (now == l) {
			sum += (arr[r] - arr[l]) * (arr[r] - arr[l]);
			now = r; l++;
		}
		else {
			sum += (arr[r] - arr[l]) * (arr[r] - arr[l]);
			now = l; r--;
		}
	}
	cout << sum;
	return 0;
}